void regroup_tcp(const u_char *org_data, u_char **new_data, int size, address_group ag) {
	ip_header *iph = (ip_header *)(org_data + 14);
	int tcp_start;

	tcp_start = 14 + (iph->ver_ihl & 0x0F) * 4;

	memcpy(*new_data, org_data, sizeof(u_char)*size);

	/* source mac address */
	(*new_data)[0] = ag.mdest.byte1;
	(*new_data)[1] = ag.mdest.byte2;
	(*new_data)[2] = ag.mdest.byte3;
	(*new_data)[3] = ag.mdest.byte4;
	(*new_data)[4] = ag.mdest.byte5;
	(*new_data)[5] = ag.mdest.byte6;

	/* destination mac address */
	(*new_data)[6] = ag.msrc.byte1;
	(*new_data)[7] = ag.msrc.byte2;
	(*new_data)[8] = ag.msrc.byte3;
	(*new_data)[9] = ag.msrc.byte4;
	(*new_data)[10] = ag.msrc.byte5;
	(*new_data)[11] = ag.msrc.byte6;

	/* source ip address */
	(*new_data)[26] = ag.isrc.byte1;
	(*new_data)[27] = ag.isrc.byte2;
	(*new_data)[28] = ag.isrc.byte3;
	(*new_data)[29] = ag.isrc.byte4;



	/* destination ip address */
	(*new_data)[30] = ag.idest.byte1;
	(*new_data)[31] = ag.idest.byte2;
	(*new_data)[32] = ag.idest.byte3;
	(*new_data)[33] = ag.idest.byte4;

	/* source and destination port */
	*(u_short *)(*new_data + tcp_start) = htons(ag.psrc);
	*(u_short *)(*new_data + tcp_start + 2) = htons(ag.pdest);

	*(u_short *)(*new_data + 24) = calc_IP_chk(*new_data);
	*(u_short *)(*new_data + tcp_start + 16) = calc_TCP_chk(*new_data, ntohs(iph->tlen));
}

void regroup_udp(const u_char *org_data, u_char **new_data, int size, address_group ag) {
	ip_header *iph = (ip_header *)(org_data + 14);
	int udp_start;

	udp_start = 14 + (iph->ver_ihl & 0x0F) * 4;
	memcpy(*new_data, org_data, sizeof(u_char)*size);

	/* source mac address */
	(*new_data)[0] = ag.mdest.byte1;
	(*new_data)[1] = ag.mdest.byte2;
	(*new_data)[2] = ag.mdest.byte3;
	(*new_data)[3] = ag.mdest.byte4;
	(*new_data)[4] = ag.mdest.byte5;
	(*new_data)[5] = ag.mdest.byte6;

	/* destination mac address */
	(*new_data)[6] = ag.msrc.byte1;
	(*new_data)[7] = ag.msrc.byte2;
	(*new_data)[8] = ag.msrc.byte3;
	(*new_data)[9] = ag.msrc.byte4;
	(*new_data)[10] = ag.msrc.byte5;
	(*new_data)[11] = ag.msrc.byte6;

	/* source ip address */
	(*new_data)[26] = ag.isrc.byte1;
	(*new_data)[27] = ag.isrc.byte2;
	(*new_data)[28] = ag.isrc.byte3;
	(*new_data)[29] = ag.isrc.byte4;

	/* destination ip address */
	(*new_data)[30] = ag.idest.byte1;
	(*new_data)[31] = ag.idest.byte2;
	(*new_data)[32] = ag.idest.byte3;
	(*new_data)[33] = ag.idest.byte4;

	/* source and destination port */
	*(u_short *)(*new_data + udp_start) = htons(ag.psrc);
	*(u_short *)(*new_data + udp_start + 2) = htons(ag.pdest);

	*(u_short *)(*new_data + 24) = calc_IP_chk(*new_data);
	if (*(u_short *)(org_data + udp_start + 6) != 0) {
		u_short tmp = calc_UDP_chk(*new_data, ntohs(iph->tlen));

		if (tmp != 0)
			*(u_short *)(*new_data + udp_start + 6) = tmp;
		else
			*(u_short *)(*new_data + udp_start + 6) = 0xFFFF;
	}
}